package com.systar.activity.report.actions;

import java.io.IOException;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.systar.activity.report.ActivityData;
import com.systar.activity.report.ActivityDataPool;
import com.systar.activity.report.RequestParameter;

abstract class DataManipulation implements ActionProcessor
{

	@Override
	public void process(HttpServletRequest request, HttpServletResponse response, Map<RequestParameter, String> parameters, ActivityDataPool data)
			throws ServletException, IOException
	{
    	String source = parameters.get(RequestParameter.source);
    	if (source == null)
    		return;
    	
		ActivityData activity = new ActivityData(source);
		processData(activity, parameters);
		data.appendData(activity); // minimum synchronization overhead
	}

	protected abstract void processData(ActivityData activity, Map<RequestParameter, String> parameters);
}
